package pl.prv.polanie.client.widgets;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.user.client.ui.ChangeListener;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.ListBox;


public class ListBoxWithObjects extends Composite {

	private ListBox listBox = new ListBox();
	
	/** list of Object objects*/
	private List objects = new ArrayList();
	
	public ListBoxWithObjects() {
		initWidget(listBox);
	}
	
	
	public void addItem(String item, Object object) {
		listBox.addItem(item);
		objects.add(object);
	}


	public void addChangeListener(ChangeListener listener) {
		listBox.addChangeListener(listener);
	}


	public void clear() {
		listBox.clear();
		objects.clear();
	}


	public int getItemCount() {
		return listBox.getItemCount();
	}


	public String getItemText(int index) {
		return listBox.getItemText(index);
	}


	public int getSelectedIndex() {
		return listBox.getSelectedIndex();
	}


	public String getValue(int index) {
		return listBox.getValue(index);
	}


	public void setSelectedIndex(int index) {
		listBox.setSelectedIndex(index);
	};
	
	public Object getObject(int index) {
		return objects.get(index);
	}
	
	public Object getSelectedObject() {
		return objects.get(listBox.getSelectedIndex());
	}

	
	
	
	
}
